<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="88px">
      <el-form-item label="线路编号" prop="routeNo">
        <el-input v-model="queryParams.routeNo" placeholder="请输入线路编号" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="线路名称" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入线路名称" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="业务类型" prop="opTpye">
        <el-input v-model="queryParams.opTpye" placeholder="请输入业务类型" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="线路类别" prop="lineTpye">
        <el-input v-model="queryParams.lineTpye" placeholder="请输入线路类别" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="执行日期" prop="runDate">
        <el-date-picker clearable v-model="queryParams.runDate" type="date" value-format="YYYY-MM-DD"
          placeholder="请选择执行日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="执行班次" prop="shift">
        <el-select v-model="queryParams.shift" placeholder="请选择班次" clearable>
          <el-option v-for="dict in execution_shift_1" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="车辆自编号" prop="vehicleId">
        <el-input v-model="queryParams.vehicleId" placeholder="请选择车辆" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="线路状态" prop="status">
        <el-input v-model="queryParams.status" placeholder="请输入线路状态" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5"> 
        <el-label class="label">综合：</el-label>
       </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['service:route:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
          v-hasPermi="['service:route:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['service:route:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="Check" @click="handleAudit">调度经理审核</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="Check" @click="handleConfirm">取消确认</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="info" plain icon="Plus" @click="handleAddTask">追加任务</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="Minus" @click="handleRemoveTask">解除任务</el-button> 
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="Close" @click="handleCancelAtmTask">取消ATM任务</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="Check" @click="handleEndLine">结束线路</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain icon="Printer" @click="handlePrintAtmTask">打印ATM任务单</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain icon="Printer" @click="handlePrintLineTransfer">打印ATM线路交接表</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="info" plain icon="Link" @click="handleBindSwallowCard">线路绑定吞卡</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="Message" @click="handleSendSchedule">发送排班消息</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="Download" @click="handleExport"
          v-hasPermi="['service:route:export']">导出</el-button>
      </el-col>
    </el-row>
    <el-row :gutter="10" class="mb8">
       <el-label class="label">早送晚接：</el-label>
       <el-button type="warning" plain icon="Message" @click="handleSendSchedule">群送排班消息</el-button>
    </el-row>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5"> 
        <el-label class="label">ATM：</el-label>
       </el-col>
       <el-col :span="1.5"> 
        <el-button type="warning" plain icon="Setting" @click="handleSendSchedule">补充时间</el-button>
       </el-col>
       <el-col :span="1.5"> 
        <el-button type="info" plain icon="Message" @click="handleSendSchedule">查看线路支援</el-button>
      </el-col>
      <el-col :span="1.5"> 
        <el-button type="success" plain icon="Edit" @click="handleSendSchedule">更换车辆</el-button>
      </el-col>
      <el-col :span="1.5"> 
        <el-button type="warning" plain icon="Message" @click="handleSendSchedule">群发排班消息</el-button>
      </el-col>
       <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="routeList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="路线ID" align="center" prop="id" />
      <el-table-column label="线路编号" align="center" prop="routeNo" />
      <el-table-column label="线路名称" align="center" prop="name" />
      <el-table-column label="业务类型" align="center" prop="opTpye" />
      <el-table-column label="区域ID" align="center" prop="areaId" />
      <el-table-column label="线路类别" align="center" prop="lineTpye" />
      <el-table-column label="执行日期" align="center" prop="runDate" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.runDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计划开始时间" align="center" prop="planBeginTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.planBeginTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计划结束时间" align="center" prop="planEndTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.planEndTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="执行班次" align="center" prop="shift">
        <template #default="scope">
          <dict-tag :options="execution_shift_1" :value="scope.row.shift" />
        </template>
      </el-table-column>
      <el-table-column label="业务员(钥匙员)" align="center" prop="lockerId" />
      <el-table-column label="业务员(密码员)" align="center" prop="pwdId" />
      <el-table-column label="押运员1" align="center" prop="securityAId" />
      <el-table-column label="押运员2" align="center" prop="securityBId" />
      <el-table-column label="司机" align="center" prop="driverId" />
      <el-table-column label="跟车司机" align="center" prop="followDriverId" />
      <el-table-column label="跟车学习人员" align="center" prop="followLearnerId" />
      <el-table-column label="车辆id" align="center" prop="vehicleId" />
      <el-table-column label="Ibutton" align="center" prop="atmIbuttonId" />
      <el-table-column label="PDA" align="center" prop="pdaId" />
      <el-table-column label="线路备注" align="center" prop="routeRemark" />
      <el-table-column label="ATM任务列表" align="center" prop="atmTaskIdList" />
      <el-table-column label="早送晚收任务列表" align="center" prop="zswsTaskIdList" />
      <el-table-column label="atm押运物品" align="center" prop="suppliersList" />
      <el-table-column label="回线钞箱个数" align="center" prop="returnBoxCounts" />
      <el-table-column label="业务员绩效档位" align="center" prop="zswsOperTier" />
      <el-table-column label="司机绩效档位" align="center" prop="zswsDriverTier" />
      <el-table-column label="司机是否兼职业务" align="center" prop="zswsPartTimeDriver" />
      <el-table-column label="押运员领枪时长" align="center" prop="getGunMinute" />
      <el-table-column label="司机领钥匙时长" align="center" prop="getKeyMinute" />
      <el-table-column label="领任务单时长" align="center" prop="getListMinute" />
      <el-table-column label="是否途径佛山" align="center" prop="isThroughFoshan" />
      <el-table-column label="是否单次收费线路" align="center" prop="isOneWayRoute" />
      <el-table-column label="是否去人行" align="center" prop="isToPboc">
        <template #default="scope">
          <dict-tag :options="sys_yes_no" :value="scope.row.isToPboc" />
        </template>
      </el-table-column>
      <el-table-column label="是否去机场" align="center" prop="isToAirport">
        <template #default="scope">
          <dict-tag :options="sys_yes_no" :value="scope.row.isToAirport" />
        </template>
      </el-table-column>
      <el-table-column label="是否去农商广州库房" align="center" prop="isToGzrbc">
        <template #default="scope">
          <dict-tag :options="sys_yes_no" :value="scope.row.isToGzrbc" />
        </template>
      </el-table-column>
      <el-table-column label="是否需要枪柜钥匙" align="center" prop="isNeedKeyOfGunBox">
        <template #default="scope">
          <dict-tag :options="sys_yes_no" :value="scope.row.isNeedKeyOfGunBox" />
        </template>
      </el-table-column>
      <el-table-column label="是否需要单页打印" align="center" prop="isPrintOneSide">
        <template #default="scope">
          <dict-tag :options="sys_yes_no" :value="scope.row.isPrintOneSide" />
        </template>
      </el-table-column>
      <el-table-column label="线路状态" align="center" prop="status" />
      <el-table-column label="人员到岗时间" align="center" prop="beginTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.beginTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="从金库出发时间" align="center" prop="outTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.outTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="返回金库时间" align="center" prop="backTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.backTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="任务备注" align="center" prop="remark" />
      <el-table-column label="审核者" align="center" prop="checkBy" />
      <el-table-column label="审核时间" align="center" prop="checkTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.checkTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize" @pagination="getList" />

    <!-- 添加或修改线路管理对话框 -->
    <el-dialog :title="title" v-model="open" width="500px" append-to-body>
      <el-form ref="routeRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="线路编号" prop="routeNo">
          <el-input v-model="form.routeNo" placeholder="请输入线路编号" />
        </el-form-item>
        <el-form-item label="线路名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入线路名称" />
        </el-form-item>
        <el-form-item label="区域ID" prop="areaId">
          <el-input v-model="form.areaId" placeholder="请输入区域ID" />
        </el-form-item>
        <el-form-item label="执行日期" prop="runDate">
          <el-date-picker clearable v-model="form.runDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择执行日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划开始时间" prop="planBeginTime">
          <el-date-picker clearable v-model="form.planBeginTime" type="date" value-format="YYYY-MM-DD"
            placeholder="请选择计划开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划结束时间" prop="planEndTime">
          <el-date-picker clearable v-model="form.planEndTime" type="date" value-format="YYYY-MM-DD"
            placeholder="请选择计划结束时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="班次A/B/C" prop="shift">
          <el-select v-model="form.shift" placeholder="请选择班次A/B/C">
            <el-option v-for="dict in execution_shift_1" :key="dict.value" :label="dict.label"
              :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="钥匙员/业务员A" prop="lockerId">
          <el-input v-model="form.lockerId" placeholder="请输入钥匙员/业务员A" />
        </el-form-item>
        <el-form-item label="密码员/业务员B" prop="pwdId">
          <el-input v-model="form.pwdId" placeholder="请输入密码员/业务员B " />
        </el-form-item>
        <el-form-item label="押运员1的ID" prop="securityAId">
          <el-input v-model="form.securityAId" placeholder="请输入押运员1的ID" />
        </el-form-item>
        <el-form-item label="押运员2的ID" prop="securityBId">
          <el-input v-model="form.securityBId" placeholder="请输入押运员2的ID" />
        </el-form-item>
        <el-form-item label="司机id" prop="driverId">
          <el-input v-model="form.driverId" placeholder="请输入司机id" />
        </el-form-item>
        <el-form-item label="跟车司机id" prop="followDriverId">
          <el-input v-model="form.followDriverId" placeholder="请输入跟车司机id" />
        </el-form-item>
        <el-form-item label="跟车学习人员" prop="followLearnerId">
          <el-input v-model="form.followLearnerId" placeholder="请输入跟车学习人员id" />
        </el-form-item>
        <el-form-item label="车辆id" prop="vehicleId">
          <el-input v-model="form.vehicleId" placeholder="请输入车辆id" />
        </el-form-item>
        <el-form-item label="Ibutton id" prop="atmIbuttonId">
          <el-input v-model="form.atmIbuttonId" placeholder="请输入Ibutton id,关联Ibutton表" />
        </el-form-item>
        <el-form-item label="PDA id" prop="pdaId">
          <el-input v-model="form.pdaId" placeholder="请输入PDA id,关联PDA表" />
        </el-form-item>
        <el-form-item label="线路备注" prop="routeRemark">
          <el-input v-model="form.routeRemark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="ATM任务列表" prop="atmTaskIdList">
          <el-input v-model="form.atmTaskIdList" placeholder="请输入ATM任务列表" />
        </el-form-item>
        <el-form-item label="早送晚收任务列表" prop="zswsTaskIdList">
          <el-input v-model="form.zswsTaskIdList" placeholder="请输入早送晚收任务列表" />
        </el-form-item>
        <el-form-item label="atm押运物品" prop="suppliersList">
          <el-input v-model="form.suppliersList" placeholder="请输入atm押运物品" />
        </el-form-item>
        <el-form-item label="回线钞箱个数" prop="returnBoxCounts">
          <el-input v-model="form.returnBoxCounts" placeholder="请输入回线钞箱个数" />
        </el-form-item>
        <el-form-item label="业务员绩效档位" prop="zswsOperTier">
          <el-input v-model="form.zswsOperTier" placeholder="请输入业务员绩效档位" />
        </el-form-item>
        <el-form-item label="司机绩效档位" prop="zswsDriverTier">
          <el-input v-model="form.zswsDriverTier" placeholder="请输入司机绩效档位" />
        </el-form-item>
        <el-form-item label="司机是否兼职业务" prop="zswsPartTimeDriver">
          <el-input v-model="form.zswsPartTimeDriver" placeholder="请输入司机是否兼职业务" />
        </el-form-item>
        <el-form-item label="押运员领枪时长" prop="getGunMinute">
          <el-input v-model="form.getGunMinute" placeholder="请输入押运员领枪时长" />
        </el-form-item>
        <el-form-item label="司机领钥匙时长" prop="getKeyMinute">
          <el-input v-model="form.getKeyMinute" placeholder="请输入司机领钥匙时长" />
        </el-form-item>
        <el-form-item label="领任务单时长" prop="getListMinute">
          <el-input v-model="form.getListMinute" placeholder="请输入领任务单时长" />
        </el-form-item>
        <el-form-item label="是否途径佛山" prop="isThroughFoshan">
          <el-input v-model="form.isThroughFoshan" placeholder="请输入是否途径佛山" />
        </el-form-item>
        <el-form-item label="是否单次收费线路" prop="isOneWayRoute">
          <el-input v-model="form.isOneWayRoute" placeholder="请输入是否单次收费线路" />
        </el-form-item>
        <el-form-item label="是否去人行" prop="isToPboc">
          <el-select v-model="form.isToPboc" placeholder="请选择是否去人行">
            <el-option v-for="dict in sys_yes_no" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否去机场" prop="isToAirport">
          <el-select v-model="form.isToAirport" placeholder="请选择是否去机场">
            <el-option v-for="dict in sys_yes_no" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否去农商广州库房" prop="isToGzrbc">
          <el-select v-model="form.isToGzrbc" placeholder="请选择是否去农商广州库房">
            <el-option v-for="dict in sys_yes_no" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否需要枪柜钥匙" prop="isNeedKeyOfGunBox">
          <el-select v-model="form.isNeedKeyOfGunBox" placeholder="请选择是否需要枪柜钥匙">
            <el-option v-for="dict in sys_yes_no" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否需要单页打印" prop="isPrintOneSide">
          <el-select v-model="form.isPrintOneSide" placeholder="请选择是否需要单页打印">
            <el-option v-for="dict in sys_yes_no" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="线路状态" prop="status">
          <el-input v-model="form.status" placeholder="请输入线路状态" />
        </el-form-item>
        <el-form-item label="人员到岗时间" prop="beginTime">
          <el-date-picker clearable v-model="form.beginTime" type="date" value-format="YYYY-MM-DD"
            placeholder="请选择人员到岗时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="从金库出发时间" prop="outTime">
          <el-date-picker clearable v-model="form.outTime" type="date" value-format="YYYY-MM-DD"
            placeholder="请选择从金库出发时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="返回金库时间" prop="backTime">
          <el-date-picker clearable v-model="form.backTime" type="date" value-format="YYYY-MM-DD"
            placeholder="请选择返回金库时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="任务备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Route">
import { listRoute, getRoute, delRoute, addRoute, updateRoute } from "@/api/service/route"

const { proxy } = getCurrentInstance()
const { sys_yes_no, execution_shift_1 } = proxy.useDict('sys_yes_no', 'execution_shift_1')

const routeList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    routeNo: null,
    name: null,
    opTpye: null,
    areaId: null,
    lineTpye: null,
    runDate: null,
    planBeginTime: null,
    planEndTime: null,
    shift: null,
    lockerId: null,
    pwdId: null,
    securityAId: null,
    securityBId: null,
    driverId: null,
    followDriverId: null,
    followLearnerId: null,
    vehicleId: null,
    atmIbuttonId: null,
    pdaId: null,
    routeRemark: null,
    atmTaskIdList: null,
    zswsTaskIdList: null,
    suppliersList: null,
    returnBoxCounts: null,
    zswsOperTier: null,
    zswsDriverTier: null,
    zswsPartTimeDriver: null,
    getGunMinute: null,
    getKeyMinute: null,
    getListMinute: null,
    isThroughFoshan: null,
    isOneWayRoute: null,
    isToPboc: null,
    isToAirport: null,
    isToGzrbc: null,
    isNeedKeyOfGunBox: null,
    isPrintOneSide: null,
    status: null,
    beginTime: null,
    outTime: null,
    backTime: null,
  },
  rules: {
    routeNo: [
      { required: true, message: "线路编号不能为空", trigger: "blur" }
    ],
    name: [
      { required: true, message: "线路名称不能为空", trigger: "blur" }
    ],
    opTpye: [
      { required: true, message: "业务类型不能为空", trigger: "blur" }
    ],
    runDate: [
      { required: true, message: "执行日期不能为空", trigger: "blur" }
    ],
    planBeginTime: [
      { required: true, message: "计划开始时间不能为空", trigger: "blur" }
    ],
    planEndTime: [
      { required: true, message: "计划结束时间不能为空", trigger: "blur" }
    ],
    shift: [
      { required: true, message: "班次A/B/C不能为空", trigger: "change" }
    ],
  }
})

const { queryParams, form, rules } = toRefs(data)

/** 查询线路管理列表 */
function getList() {
  loading.value = true
  listRoute(queryParams.value).then(response => {
    routeList.value = response.rows
    total.value = response.total
    loading.value = false
  })
}

// 取消按钮
function cancel() {
  open.value = false
  reset()
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    routeNo: null,
    name: null,
    opTpye: null,
    areaId: null,
    lineTpye: null,
    runDate: null,
    planBeginTime: null,
    planEndTime: null,
    shift: null,
    lockerId: null,
    pwdId: null,
    securityAId: null,
    securityBId: null,
    driverId: null,
    followDriverId: null,
    followLearnerId: null,
    vehicleId: null,
    atmIbuttonId: null,
    pdaId: null,
    routeRemark: null,
    atmTaskIdList: null,
    zswsTaskIdList: null,
    suppliersList: null,
    returnBoxCounts: null,
    zswsOperTier: null,
    zswsDriverTier: null,
    zswsPartTimeDriver: null,
    getGunMinute: null,
    getKeyMinute: null,
    getListMinute: null,
    isThroughFoshan: null,
    isOneWayRoute: null,
    isToPboc: null,
    isToAirport: null,
    isToGzrbc: null,
    isNeedKeyOfGunBox: null,
    isPrintOneSide: null,
    status: null,
    beginTime: null,
    outTime: null,
    backTime: null,
    remark: null,
    createTime: null,
    createBy: null,
    updateTime: null,
    updateBy: null,
    checkBy: null,
    checkTime: null
  }
  proxy.resetForm("routeRef")
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1
  getList()
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef")
  handleQuery()
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id)
  single.value = selection.length != 1
  multiple.value = !selection.length
}

/** 新增按钮操作 */
function handleAdd() {
  reset()
  open.value = true
  title.value = "添加线路管理"
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset()
  const _id = row.id || ids.value
  getRoute(_id).then(response => {
    form.value = response.data
    open.value = true
    title.value = "修改线路管理"
  })
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["routeRef"].validate(valid => {
    if (valid) {
      if (form.value.id != null) {
        updateRoute(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功")
          open.value = false
          getList()
        })
      } else {
        addRoute(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功")
          open.value = false
          getList()
        })
      }
    }
  })
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value
  proxy.$modal.confirm('是否确认删除线路管理编号为"' + _ids + '"的数据项？').then(function () {
    return delRoute(_ids)
  }).then(() => {
    getList()
    proxy.$modal.msgSuccess("删除成功")
  }).catch(() => { })
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('service/route/export', {
    ...queryParams.value
  }, `route_${new Date().getTime()}.xlsx`)
}

getList()
</script>

<!-- 全局设置el-input宽度 -->
<style scoped>
:deep(.el-input),
:deep(.el-select .el-input) {
  width: 215px;
  box-sizing: border-box;
}
</style>